package test1;

class MyRunnable implements Runnable {
    @Override
    public void run() {
        while (true) {
            System.out.println("hello thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

public class demo1 {
    public static void main(String[] args){


        Thread thread=new Thread(()->{
           while(true){
               System.out.println("hello threat");
               try{
                   Thread.sleep(1000);
               }catch(InterruptedException e){
                   e.printStackTrace();
               }
           }
        });


        Thread t1=new MyThread();
        t1.start();


        Runnable runnable=new MyRunnable();
        Thread t=new Thread(()->{
            while (true){
                System.out.println("hello runnable");
                try{
                    Thread.sleep(1000);
                }catch(InterruptedException e){
                    e.printStackTrace();
                }
            }
        });


        thread.start();
        t.start();
    }
}
